package com.common.client;

import com.smartgwt.client.widgets.Dialog;
import com.smartgwt.client.widgets.HTMLPane;

public class SplashDialog extends Dialog {
	private static SplashDialog splashDialog = null;

	public SplashDialog() {
		this.setSize("120", "85");
		HTMLPane pane = new HTMLPane();
		pane.setContents("<b>Loading<b><img src=\"images/loading.gif\" width=\"16\" height=\"16\" style=\"margin-right:8px;float:left;vertical-align:top;\"/>");
		pane.setWidth100();
		pane.setHeight100();
		pane.setBorder("1px solid gray");
		this.addItem(pane);
		this.setAutoCenter(true);
		this.setIsModal(true);
		this.setShowHeader(false);
		this.setShowEdges(false);
		this.centerInPage();
	}

	public static void showSplash() {
		if (splashDialog == null)
			splashDialog = new SplashDialog();
		splashDialog.centerInPage();
		splashDialog.show();
	}

	public static void hideSplash() {
		if (splashDialog == null)
			return;
		splashDialog.hide();
		splashDialog.destroy();
		splashDialog = null;
	}
}
